package com.herohead;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class MySQL {

	String dbURL = "";
	String username ="";
	String password = "";

	String query = null;
	public Connection dbCon = null;
	public Statement stmt = null;
	public ResultSet rs = null;

	public void connect(String dbURL,String username,String password) throws SQLException {
		dbCon = DriverManager.getConnection(dbURL, username, password);
		stmt = dbCon.createStatement();
	}

	public void exec_query(String strQuery) throws SQLException {
		prepareStatement(strQuery);
		rs = stmt.executeQuery(strQuery);
	}
	public void exec_statement(String strQuery) throws SQLException {
		prepareStatement(strQuery);
		stmt.execute(strQuery);
	}
	public String getdbURL() {
		return dbURL;
	}

	public String getPassword() {
		return password;
	}

	public String getPreparedStatement() {
		return query;
	}

	public ResultSet getResult() {
		return rs;
	}

	public String getUsername() {
		return username;
	}
	public void prepareStatement(String strQuery) throws SQLException {
		query = strQuery;
		stmt = dbCon.prepareStatement(strQuery);
	}

	public void setupConnection(String strDbUrl, String strUsername, String strPassword) throws SQLException {
		dbURL = strDbUrl;
		username = strUsername;
		password = strPassword;
		connect(dbURL,username,password);
	}




}
